
#ifndef _BSP_SMART_CARD_H_
#define _BSP_SMART_CARD_H_

#include "IO.h"
#include "fifo.h"

#define DIRECT_BYTE		0
#define REVERSE_BYTE	1


struct hardwarem_module_tag
{
	uint32_t usart;
//		uint32_t *parity_odd;
	AFIO_T ck;
	uint8_t byte_direction;
	uint8_t transfer_direction;
	uint16_t send_complete_flag;
	uint32_t frequency_fraction;
	uint8_t number;
};

typedef struct hardwarem_module_tag hardware_module_t;

void HardwareModule_Init(void);
void HardwareModule_SetByteDirection(hardware_module_t *hw, uint8_t dir);
void HardwareModule_SetETU(hardware_module_t *hw, uint8_t FiDi);
uint8_t HardwareModule_SendByte(hardware_module_t *hw, uint8_t byte);
uint8_t HardwareModule_CheckNAK(hardware_module_t *hw);
uint8_t HardwareModule_ReceiveByte(hardware_module_t *hw, uint16_t *byte, uint32_t clk);
void HardwareModule_NAKEnable(hardware_module_t *hw);
void HardwareModule_NAKDisable(hardware_module_t *hw);
uint16_t HardwareModule_Flush(hardware_module_t *hw);
void HardwareModule_SetStopbits(hardware_module_t *hw, uint8_t stopbits);
void HardwareModule_SetStopbits(hardware_module_t *hw, uint8_t stopbits);
void HardwareModule_SetFrequency(hardware_module_t *hw, uint32_t frequency);

void HardwareModule_ClockEnable(hardware_module_t *hw);
void HardwareModule_ClockDisable(hardware_module_t *hw);
void HardwareModule_SetCharDuration(hardware_module_t *hw, uint8_t char_duration);

void HardwareModule_SoftwareNak(uint8_t FiDi);
void HardwareModule_Reset(hardware_module_t *hw);

#endif

